#pragma once
#include "files_needed.h"
#include "BaseObject.h"
#include "Asset Library.h"
#include "templatevector.h"
#include "GUI_Morph.h"

struct color
{
	unsigned red, green, blue;
	color() : red(0), green(0), blue(0) {}
	color(int r, int g, int b) : red(r), green(g), blue(b) {}
	//color operator=(int i) { red = green = blue = i; }
	color(int i) : red(i), blue(i), green(i) {}
};

// this class uses purely DirectX calls in order to draw to the screen
class DXEngine
{
private:
	IDirect3DDevice9*		m_pD3DDevice;						// the main device
	ID3DXFont*				m_pFontManager;						// for drawing text to the screen
	ID3DXSprite*			m_pSpriteManager;					// for drawing sprites to the screen
	D3DPRESENT_PARAMETERS	m_D3Dpp;							// the presentation parameters used for initialization

	bool InitDevice(HWND hWnd, int scrHeight, int scrWidth);	// initializes the main device
	bool InitManagers();										// initializes managers like m_pFontManager and m_pSpriteManager
	void Draw(BaseObject* pObj);								// method for drawing one object on the screen
	void Draw(char* ,int x,int y,int h,int w);

	D3DXMATRIX			rotMat, scaleMat,transMat;
	D3DXVECTOR3	*		ObjPos;
	LPDIRECT3DTEXTURE9	ObjTex;

	Library<LPDIRECT3DTEXTURE9> m_D3DXTextures;					// All the directx textures that have been loaded

	TemplateVector<TextBox>		m_AllMenuText;

public:
	DXEngine();
	bool	Init(HWND hWnd, int scrHeight, int scrWidth);
	int		AddAsset(char* texLoc, color cKey);
	point	GetAssetDimensions(int index);
	bool	RemoveAsset(int index);

	//void	BeginScene();
	//void	BeginSprite();
	void	Render(IndexedLinkedList*, IndexedLinkedList*);
	//void	RenderMenu(IndexedLinkedList*);
	//void	RenderMenuText();
	//void	EndScene();
	//void	EndSprite();
	void	Release();
	~DXEngine();
};